/**
 * 拷贝src 到dist目录
* @description
*/
const fs = require('fs');

const copy = (src, dist) => {
  const data = fs.readdirSync(src)
  data.forEach(item => {
    let _src = src + '/' + item;
    let _dist = dist + '/' + item;
    let isStat = fs.statSync(_src)
    if (isStat.isDirectory()) {
      exists(_src, _dist)
    } else if (isStat.isFile()) {
      let data = fs.readFileSync(_src)
      fs.writeFileSync(_dist, data)
    }
  })
}
const exists = (src, dist) => {
  if (fs.existsSync(dist)) {
    copy(src, dist)
  } else {
    fs.mkdirSync(dist)
    copy(src, dist)
  }
}

exists('./src', './dist')
